package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Ware;
import com.skyolder.milkbee.repository.WareRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Ware.
 */
@Service
@Transactional
public class WareService {

    private final Logger log = LoggerFactory.getLogger(WareService.class);
    
    @Inject
    private WareRepository wareRepository;

    /**
     * Save a ware.
     *
     * @param ware the entity to save
     * @return the persisted entity
     */
    public Ware save(Ware ware) {
        log.debug("Request to save Ware : {}", ware);
        Ware result = wareRepository.save(ware);
        return result;
    }

    /**
     *  Get all the wares.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Ware> findAll(Pageable pageable) {
        log.debug("Request to get all Wares");
        Page<Ware> result = wareRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one ware by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Ware findOne(Long id) {
        log.debug("Request to get Ware : {}", id);
        Ware ware = wareRepository.findOne(id);
        return ware;
    }

    /**
     *  Delete the  ware by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Ware : {}", id);
        wareRepository.delete(id);
    }
}
